import { createRouter, createWebHashHistory } from "vue-router";
import { useAuthStore } from "@/stores/auth";
import frame_router from "@/router/frame";
import login_router from "@/router/login";
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),

  routes: frame_router.concat(login_router)
});

router.beforeEach((to, from) => {
  const authStore = useAuthStore();

  if (!authStore.is_login && to.name !== "login") {
    return { name: "login" };
  }
});

export default router;
